package leetcode14;

public class test75 {
    /**
     * 45. 跳跃游戏 II
     * @param nums
     * @return
     */
    public int jump(int[] nums) {
        int mx = 0;
        int end = 0;
        int n = nums.length;
        int step = 0;
        for(int i = 0;i < n - 1;i++){
            mx = Math.max(mx,i + nums[i]);
            if(i == end){
                end = mx;
                step++;
            }
        }
        return step;
    }
}
